package com.framewiki.example.ai;

import com.cdkjframework.ai.AiUtils;
import com.cdkjframework.ai.core.AiService;
import com.cdkjframework.ai.enums.Qwen;
import com.cdkjframework.ai.model.qwen.QwenConfig;
import com.cdkjframework.ai.model.qwen.QwenService;
import com.cdkjframework.ai.model.qwen.impl.QwenServiceImpl;
import com.cdkjframework.core.spring.CdkjApplication;
import com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @ProjectName: framewiki-example
 * @Package: com.framewiki.example.ai
 * @ClassName: AiApplication
 * @Description: AI应用启动
 * @Author: xiaLin
 * @Date: 2025/7/20 21:19
 * @Version: 1.0
 */
@Configuration
@SpringBootApplication(scanBasePackages = {
    "com.framewiki.example",
    "com.cdkjframework.util",
    "com.cdkjframework.core",
    "com.cdkjframework.entity",
    "com.cdkjframework.config",
    "com.cdkjframework.constant"
}, exclude = {PageHelperAutoConfiguration.class,
    DataSourceAutoConfiguration.class,
    MultipartAutoConfiguration.class})
public class AiApplication {

  /**
   * 主函数
   *
   * @param args 参数
   */
  public static void main(String[] args) {
    CdkjApplication.run(AiApplication.class, args);
    QwenConfig config = new QwenConfig();
    config.setApiKey("sk-xxxx");
    QwenService chatService = (QwenService) AiUtils.findAiService(config);
    System.out.printf("AI回复" + chatService.chat("你好，请介绍一下你呢。"));

    config.setModel(Qwen.QWEN_VL_MAX_LATEST.getModel());
    QwenService service = AiUtils.findAiService(config, QwenService.class);
    System.out.printf("AI回复" + service.chatVision(List.of("介绍这个图片。"), List.of("https://framewiki.com/logo.png")));
  }
}
